package com.softcomputer.rpt.web;

import com.softcomputer.rpt.ejb.ExCourseSession;
import com.softcomputer.rpt.ejb.UserSession;
import com.softcomputer.rpt.entity.ExCourse;
import java.math.BigDecimal;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "course")
@SessionScoped
public class CoursesManagementBean {

    @EJB
    private UserSession userSession;
    @EJB
    private ExCourseSession exCourseSession;
    private ExCourse course;
    private List<BigDecimal> values;
    private List<String> currencies;
    private String currency;

    public CoursesManagementBean() {
    }

    public List<BigDecimal> getValues() {
        values = exCourseSession.getValues();
        return values;
    }

    public List<ExCourse> getExchangeCourses() {
        return exCourseSession.retrieve();
    }

    public List<String> getCurrencies() {
        currencies = exCourseSession.getCurrency();
        return currencies;
    }

    public ExCourse getCourse() {
        if (course == null) {
            course = new ExCourse();
        }
        return course;
    }

    public void setCurrency(String curr) {
        currency = curr;
    }

    public String getCurrency() {
        return currency;
    }

    public BigDecimal getRate() {
        return exCourseSession.getExchangeRate("DOL", "UAH");
    }
}
